//
//  LBSlidePopView.h
//  TEXT
//
//  Created by mac on 2024/7/28.
//  Copyright © 2024 刘博. All rights reserved.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@protocol LBSlidePopViewDelegate <NSObject>

- (void)slideDismiss:(NSString *)source;

@optional

- (void)didPanGesture:(UIPanGestureRecognizer *)panGesture;

@end

typedef NS_ENUM(NSInteger, LBSlideViewExpand) {
    LBSlideViewExpandNone = 0,   // 无
    LBSlideViewExpandMin = 1,
    LBSlideViewExpandMid = 2,
    LBSlideViewExpandMax = 3
};

@protocol LBPopSlideFrameDelegate <NSObject>

- (void)frameChanged:(CGRect)frame percent:(CGFloat)percent isMax:(BOOL)isMax inAnimation:(BOOL)inAnimation finished:(BOOL)finished;
- (void)frameChangedInAnimationBlock:(CGRect)frame percent:(CGFloat)percent isMax:(BOOL)isMax;
- (void)expandStatusChanged:(LBSlideViewExpand)status lastStatus:(LBSlideViewExpand)lastStatus;

// Offer区块
- (BOOL)shouldCollopseOfferView;
- (BOOL)shouldExpandOfferView;
- (void)updateOfferViewFrame:(CGFloat)offset;
- (void)collopseOrExpandOfferView;

@end

@interface LBSlidePopView : UIView

@property (nonatomic, weak) id<LBPopSlideFrameDelegate> frameDelegate;

@property (nonatomic, weak) UIView                     *contentView;   // 主内容

@property (nonatomic, strong) UITapGestureRecognizer    *tapGesture;
@property (nonatomic, strong) UIPanGestureRecognizer    *panGesture;
@property (nonatomic, strong) UILongPressGestureRecognizer *longPressGesture;

@property (nonatomic, weak) UIScrollView                *scrollView;
@property (nonatomic, assign) CGFloat beginContentOffsetY;
@property (nonatomic, assign) BOOL                      isDragScrollView;
@property (nonatomic, assign) CGFloat                   lastTransitionY;
@property (nonatomic, assign) CGFloat                   beginY;
@property (nonatomic, assign) BOOL                      hasImpactFeedback;   // 是否已经震动过
@property (nonatomic, assign) CGFloat                    slideHPercent;   // 横向滚动的阈值：用来判断是否横向滚动还是竖向滚动
///允许横向滑动消失，默认NO
@property (nonatomic, assign) BOOL horizontalPanDismiss;

@property (nonatomic, weak) id<LBSlidePopViewDelegate> delegate;

@property (nonatomic, assign) BOOL                    disableGesture;   // 是否禁用手势

//原来的内容的高度
@property (nonatomic, assign) CGFloat contentOriginHeight;


- (instancetype)initWithFrame:(CGRect)frame contentView:(UIView *)contentView maskView:(nullable UIView *)maskView delegate:(id<LBSlidePopViewDelegate>)delegate;

- (void)updateContentFrame:(CGFloat)offset;
- (void)dismiss:(NSString *)source;

- (void)updateForSingleView;

@end

NS_ASSUME_NONNULL_END
